import mock from 'mockjs'
const login = mock.mock(
  'login',
  'post',
  options => {
    const {
      username,
      password
    } = JSON.parse(options.body)
    let success = 'false'
    let errorMsg = ''
    if (!username || !username.trim()) {
      success = 'false'
      errorMsg = '请输入用户名'
    }
    //  else if (username !== 'user') {
    //   success = 'false'
    //   errorMsg = '用户名不存在'
    // }
     else if (password !== '123456') {
      success = 'false'
      errorMsg = '用户名密码不匹配'
    } else {
      success = 'true'
    }
    if (!success) {
      return {
        success,
        errorMsg
      }
    } else {
      return {
        success,
        data: {
          token: '123456789',
          username
        }
      }
    }
  }
)

export default login
